<template>
  <div class="teacher">
    <h2>我是老师，我的名字是{{name}}</h2>
    <!--默认插槽这里就展示对应的教学科目了-->
      <slot></slot>
    <span>我的学生姓名是:{{ student }}</span>
  </div>
 </template>
<script>
export default {
  name: "TeacherView",
  data(){
    return{
      name:'刘永平',
      student:'',
      
    }
  },
   mounted(){
    //获取对应的学生姓名
      this.$bus.$on('helloTeacher',(data)=>{
           this.student=data //放置对应的学生信息数组  
      })
   },
   beforeDestroy(){
     this.$bus.$off('helloTeacher') //事件解绑
   }
}
</script>
<style scoped>
.teacher{
  background-color: skyblue;
}

</style>